from django.db import models
from datetime import datetime

# Create your models here.


class UserProfile(models.Model):
    # 按次数收费2000条不显示
    # 按月会员每日发送条数受限制
    GENDER_CHOICES = (
        (1, '男'),
        (0, '女'),
        (2, '未知'),
    )

    BILLING_TYPE = (
        (1, '按月会员'),
        (2, '按次数'),
    )

    MEMBERSHIP_TYPE = (
        (1, '体验用户(每日免费5条)'),
        (2, '普通会员(每天免费30条)'),
        (3, '年费会员(不限次数)'),
    )

    username = models.CharField(max_length=50, verbose_name='用户名')
    email = models.EmailField(verbose_name='邮箱')
    phone = models.CharField(max_length=11, verbose_name='手机号')
    realName = models.CharField(max_length=10, verbose_name='真实名称')
    sex = models.SmallIntegerField(choices=GENDER_CHOICES, default=2, verbose_name='性别')
    billing_type = models.SmallIntegerField(choices=BILLING_TYPE, default=1, verbose_name='计费类型')
    membership_type = models.SmallIntegerField(choices=MEMBERSHIP_TYPE, default=1, verbose_name='会员类型')
    # gpt3_count = models.IntegerField(default=5, verbose_name='GPT3.5-turbo次数')
    # gpt4_count = models.IntegerField(default=0, verbose_name='GPT4次数')
    count = models.JSONField(default=dict, verbose_name='计费次数')
    expired = models.DateTimeField(verbose_name='会员过期时间', default=datetime.now)
    userID = models.CharField(max_length=32, verbose_name='用户ID', primary_key=True)
    uuid = models.CharField(max_length=36, verbose_name='用户UUID')

    class Meta:
        db_table = 'user_profile'
        verbose_name = '用户信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username
